package org.openkoala.koala.utils; 

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 集合工具类
 * @author zyb
 * @since 2012-11-16
 *
 */
public class CollectionUtils {

	/**
	 * 将Set转换成List
	 * @param set
	 * @return
	 */
	public static <T> List<T> asList(Set<T> set) {
		List<T> list = new ArrayList<T>();
		list.addAll(set);
		return list;
	}
	
	/**
	 * 将List转换成Set
	 * @param list
	 * @return
	 */
	public static <T> Set<T> asSet(List<T> list) {
		Set<T> set = new HashSet<T>();
		set.addAll(list);
		return set;
	}
	
	/**
	 * 将List转换成String数组
	 * @param list
	 * @return
	 */
	public static String[] toStringArray(List<String> list) {
		return list.toArray(new String[list.size()]);
	}
	
}
